package com.cqc.web;

import org.apache.tika.Tika;
import org.apache.tika.exception.TikaException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author cui
 * @date 2025/8/26 20:12
 * @description
 **/
@RestController
@RequestMapping("/tika/")
public class TikaController {

    /**
     * http://localhost:8080/tika/f1
     */
    @GetMapping("f1")
    public ResponseEntity<String> f1() throws TikaException, IOException {
        String filePath = "E:\\Java\\Spring全家桶文档\\SpringBoot教程.doc";


        Tika tika = new Tika();
        File file = new File(filePath);

        String content = tika.parseToString(file);
        return ResponseEntity.ok(content);
    }


    @GetMapping("f2")
    public ResponseEntity<String> f2() throws TikaException, IOException {
        String filePath = "C:\\Users\\cui\\Desktop\\微信撩妹72招.docx";

        Tika tika = new Tika();
        File file = new File(filePath);

        String content = tika.parseToString(file);
        return ResponseEntity.ok(content);
    }

    @GetMapping("f3")
    public ResponseEntity<String> f3() throws TikaException, IOException {
        String filePath =  "C:\\Users\\cui\\Desktop\\聊天的三阶段(1).pdf";

        Tika tika = new Tika();
        File file = new File(filePath);

        String content = tika.parseToString(file);
        return ResponseEntity.ok(content);
    }
}
